package com.hzcx.app.simplechat.ui.publicui.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.ui.publicui.bean.PayListBean;

import java.util.List;

public class PayListAdapter extends BaseQuickAdapter<PayListBean, BaseViewHolder> {

    private int pos;

    public PayListAdapter(@Nullable List<PayListBean> data) {
        super(R.layout.rv_item_pay_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PayListBean item) {
        helper.setText(R.id.tv_date, item.getMonth() + "个月");
        helper.setText(R.id.tv_price, item.getPrice() + "");
        helper.setText(R.id.tv_tips, "￥" + item.getAverage_price() + "/月");

        if (pos == helper.getAdapterPosition()) {
            helper.setBackgroundRes(R.id.ll_content, R.drawable.draw_pay_list_select_bg);
        } else {
            helper.setBackgroundRes(R.id.ll_content, R.drawable.draw_pay_list_normal_bg);
        }
    }

    public void setPos(int pos){
        this.pos=pos;
        notifyDataSetChanged();
    }
}
